﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Twi.COMMON.Core
{
    /*
     * CopyRight:©2013 Twilight软件开发工作室版权所有
     * Author:xuzhihong
     * Create Date: 2013-08-13
     * Description: SQLMap配置所需的参数实体
     */
    public class SQLMapModel
    {
        public SQLMapModel()
        {
            Parameters = new Dictionary<string, object>();
            RDACondition = new Dictionary<string, object>();
            ColNameToUpper = false;
        }
        
        /// <summary>
        /// SQLMap唯一标识编号
        /// </summary>
        public string Code
        {
            get;
            set;
        }

        /// <summary>
        /// SQLMap文件名（只是名称，非路径+名称）
        /// </summary>
        public string SQLMapFile
        {
            get;
            set;
        }

        /// <summary>
        /// 参数字典
        /// </summary>
        public Dictionary<string, object> Parameters
        {
            get;
            set;
        }

        /// <summary>
        /// 添加参数到参数字典中
        /// </summary>
        /// <param name="name">参数名称</param>
        /// <param name="value">参数值</param>
        public void AddParameter(string name, object value)
        {
            if (Parameters == null)
            {
                Parameters = new Dictionary<string, object>();
            }
            Parameters.Add(name, value);
        }

        /// <summary>
        /// 数据权限代码字典
        /// </summary>
        /// <example>
        ///     RDACondition:{                   //RDA: RoleDataAuthority 角色数据权限
        ///         DeptID:'Sys_Dept.DeptID',    //参数名为要控制的字段，参数值为bim_roledataauthority
        ///         ParkCode:'Sys_Park.ParkCode'
        ///     }
        /// </example>
        public Dictionary<string, object> RDACondition
        {
            get;
            set;
        }

        /// <summary>
        /// 添加参数到数据权限字典中
        /// </summary>
        /// <param name="name">参数名称</param>
        /// <param name="value">参数值</param>
        public void AddRDAParameter(string name, object value)
        {
            if (RDACondition == null)
            {
                RDACondition = new Dictionary<string, object>();
            }
            RDACondition.Add(name, value);
        }

        /// <summary>
        /// 是否 转化DataTable列名为大写
        /// </summary>
        public bool ColNameToUpper
        {
            get;
            set;
        }
    }
}
